package com.bangcommunity.bbframe.sdm.aop.handler;

import com.bangcommunity.bbframe.common.utils.lang.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.slf4j.Logger;

import java.lang.reflect.Method;

/**
 * Created by tanghc on 17/1/18.
 */
public class AopLogExceptionHandler extends ExceptionHandler {
    private String keyword;
    private Logger logger;

    public AopLogExceptionHandler(String keyword, Logger logger) {
        this.keyword = keyword;
        this.logger = logger;
    }

    @Override
    protected boolean doExceptionHandler(Exception e, ProceedingJoinPoint pjp, Object[] args, Method method,
            String className) {
        String argStr = StringUtils.join(args, "||");
        logger.error("!!!!  {}  {} {} exception: param={}",
                new Object[] { keyword, className, method.getName(), argStr, e });
        return true;
    }
}
